package com.yzy.spring;

import com.yzy.common.User;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Description: 手动创建spring容器，
 * 需要的依赖:
 * spring-core
 * spring-beans
 * spring-context
 * spring-expression
 * commons-logging
 *
 * Date: 2020-06-03
 *
 * @author youzhiyong
 */
public class StartContext {

    public static void main(String[] args) throws BeansException {
        try {
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");

            User user = (User) applicationContext.getBean("user");
            User user2 = (User) applicationContext.getBean("user2");
            System.out.println(user);
            System.out.println(user2);
        } catch (Exception e ) {
            System.out.println(e);
        }
    }

}
